.class public Lrexsee/storage/RexseeAsset;
.super Ljava/lang/Object;
.source "RexseeAsset.java"

# interfaces
.implements Lrexsee/core/browser/clazz/JavascriptInterface;


# static fields
.field private static final INTERFACE_NAME:Ljava/lang/String; = "Asset"


# instance fields
.field private final mBrowser:Lrexsee/core/browser/Browser;

.field private final mContext:Landroid/content/Context;


# direct methods
.method public constructor <init>(Lrexsee/core/browser/Browser;)V
    .locals 1
    .param p1, "browser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 33
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 34
    iput-object p1, p0, Lrexsee/storage/RexseeAsset;->mBrowser:Lrexsee/core/browser/Browser;

    .line 35
    invoke-virtual {p1}, Lrexsee/core/browser/Browser;->getContext()Landroid/content/Context;

    move-result-object v0

    iput-object v0, p0, Lrexsee/storage/RexseeAsset;->mContext:Landroid/content/Context;

    .line 36
    return-void
.end method


# virtual methods
.method public cleanPath(Ljava/lang/String;)Ljava/lang/String;
    .locals 2
    .param p1, "path"    # Ljava/lang/String;

    .prologue
    .line 85
    invoke-virtual {p1}, Ljava/lang/String;->toLowerCase()Ljava/lang/String;

    move-result-object v0

    const-string v1, "file:///android_asset/"

    invoke-virtual {v0, v1}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

    move-result v0

    if-eqz v0, :cond_0

    .line 86
    const/16 v0, 0x16

    invoke-virtual {p1, v0}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object v0

    .line 88
    :goto_0
    return-object v0

    :cond_0
    move-object v0, p1

    goto :goto_0
.end method

.method public copyToExternalStorage(Ljava/lang/String;Ljava/lang/String;)Z
    .locals 1
    .param p1, "path"    # Ljava/lang/String;
    .param p2, "sdPath"    # Ljava/lang/String;

    .prologue
    .line 80
    invoke-virtual {p0, p1}, Lrexsee/storage/RexseeAsset;->cleanPath(Ljava/lang/String;)Ljava/lang/String;

    move-result-object p1

    .line 81
    iget-object v0, p0, Lrexsee/storage/RexseeAsset;->mContext:Landroid/content/Context;

    invoke-static {v0, p1, p2}, Lrexsee/core/utilities/Utilities;->copyAssetToExternalStorage(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)Z

    move-result v0

    return v0
.end method

.method public exists(Ljava/lang/String;)Z
    .locals 5
    .param p1, "path"    # Ljava/lang/String;

    .prologue
    const/4 v4, 0x0

    .line 48
    invoke-virtual {p0, p1}, Lrexsee/storage/RexseeAsset;->cleanPath(Ljava/lang/String;)Ljava/lang/String;

    move-result-object p1

    .line 49
    iget-object v3, p0, Lrexsee/storage/RexseeAsset;->mContext:Landroid/content/Context;

    invoke-virtual {v3}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v3

    invoke-virtual {v3}, Landroid/content/res/Resources;->getAssets()Landroid/content/res/AssetManager;

    move-result-object v0

    .line 51
    .local v0, "am":Landroid/content/res/AssetManager;
    :try_start_0
    invoke-virtual {v0, p1}, Landroid/content/res/AssetManager;->open(Ljava/lang/String;)Ljava/io/InputStream;

    move-result-object v2

    .line 52
    .local v2, "is":Ljava/io/InputStream;
    if-eqz v2, :cond_0

    .line 53
    invoke-virtual {v2}, Ljava/io/InputStream;->close()V
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    .line 54
    const/4 v3, 0x1

    .line 57
    .end local v2    # "is":Ljava/io/InputStream;
    :goto_0
    return v3

    .restart local v2    # "is":Ljava/io/InputStream;
    :cond_0
    move v3, v4

    .line 55
    goto :goto_0

    .line 56
    .end local v2    # "is":Ljava/io/InputStream;
    :catch_0
    move-exception v3

    move-object v1, v3

    .local v1, "e":Ljava/io/IOException;
    move v3, v4

    .line 57
    goto :goto_0
.end method

.method public getContent(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    .locals 4
    .param p1, "path"    # Ljava/lang/String;
    .param p2, "encode"    # Ljava/lang/String;

    .prologue
    const-string v3, ""

    .line 61
    invoke-virtual {p0, p1}, Lrexsee/storage/RexseeAsset;->cleanPath(Ljava/lang/String;)Ljava/lang/String;

    move-result-object p1

    .line 63
    :try_start_0
    iget-object v2, p0, Lrexsee/storage/RexseeAsset;->mContext:Landroid/content/Context;

    invoke-static {v2, p1}, Lrexsee/core/utilities/Utilities;->getAssetContent(Landroid/content/Context;Ljava/lang/String;)[B

    move-result-object v0

    .line 64
    .local v0, "bytes":[B
    if-nez v0, :cond_0

    const-string v2, ""

    move-object v2, v3

    .line 66
    .end local v0    # "bytes":[B
    :goto_0
    return-object v2

    .line 64
    .restart local v0    # "bytes":[B
    :cond_0
    new-instance v2, Ljava/lang/String;

    invoke-direct {v2, v0, p2}, Ljava/lang/String;-><init>([BLjava/lang/String;)V
    :try_end_0
    .catch Ljava/io/UnsupportedEncodingException; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    .line 65
    .end local v0    # "bytes":[B
    :catch_0
    move-exception v2

    move-object v1, v2

    .line 66
    .local v1, "e":Ljava/io/UnsupportedEncodingException;
    const-string v2, ""

    move-object v2, v3

    goto :goto_0
.end method

.method public getInheritInterface(Lrexsee/core/browser/Browser;)Lrexsee/core/browser/clazz/JavascriptInterface;
    .locals 0
    .param p1, "childBrowser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 23
    return-object p0
.end method

.method public getInterfaceName()Ljava/lang/String;
    .locals 2

    .prologue
    .line 19
    new-instance v0, Ljava/lang/StringBuilder;

    iget-object v1, p0, Lrexsee/storage/RexseeAsset;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v1, v1, Lrexsee/core/browser/Browser;->application:Lrexsee/core/application/RexseeApplication;

    iget-object v1, v1, Lrexsee/core/application/RexseeApplication;->resources:Lrexsee/core/application/Resource;

    iget-object v1, v1, Lrexsee/core/application/Resource;->prefix:Ljava/lang/String;

    invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v1

    invoke-direct {v0, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v1, "Asset"

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method public getNewInterface(Lrexsee/core/browser/Browser;)Lrexsee/core/browser/clazz/JavascriptInterface;
    .locals 0
    .param p1, "childBrowser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 27
    return-object p0
.end method

.method public getSize(Ljava/lang/String;)J
    .locals 5
    .param p1, "path"    # Ljava/lang/String;

    .prologue
    .line 70
    invoke-virtual {p0, p1}, Lrexsee/storage/RexseeAsset;->cleanPath(Ljava/lang/String;)Ljava/lang/String;

    move-result-object p1

    .line 72
    :try_start_0
    iget-object v3, p0, Lrexsee/storage/RexseeAsset;->mContext:Landroid/content/Context;

    invoke-virtual {v3}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v3

    invoke-virtual {v3}, Landroid/content/res/Resources;->getAssets()Landroid/content/res/AssetManager;

    move-result-object v0

    .line 73
    .local v0, "am":Landroid/content/res/AssetManager;
    invoke-virtual {v0, p1}, Landroid/content/res/AssetManager;->open(Ljava/lang/String;)Ljava/io/InputStream;

    move-result-object v2

    .line 74
    .local v2, "in":Ljava/io/InputStream;
    invoke-virtual {v2}, Ljava/io/InputStream;->available()I
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    move-result v3

    int-to-long v3, v3

    .line 76
    .end local v0    # "am":Landroid/content/res/AssetManager;
    .end local v2    # "in":Ljava/io/InputStream;
    :goto_0
    return-wide v3

    .line 75
    :catch_0
    move-exception v3

    move-object v1, v3

    .line 76
    .local v1, "e":Ljava/lang/Exception;
    const-wide/16 v3, -0x1

    goto :goto_0
.end method

.method public list(Ljava/lang/String;)Ljava/lang/String;
    .locals 3
    .param p1, "path"    # Ljava/lang/String;

    .prologue
    .line 39
    invoke-virtual {p0, p1}, Lrexsee/storage/RexseeAsset;->cleanPath(Ljava/lang/String;)Ljava/lang/String;

    move-result-object p1

    .line 40
    iget-object v2, p0, Lrexsee/storage/RexseeAsset;->mContext:Landroid/content/Context;

    invoke-virtual {v2}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v2

    invoke-virtual {v2}, Landroid/content/res/Resources;->getAssets()Landroid/content/res/AssetManager;

    move-result-object v0

    .line 42
    .local v0, "am":Landroid/content/res/AssetManager;
    :try_start_0
    invoke-virtual {v0, p1}, Landroid/content/res/AssetManager;->list(Ljava/lang/String;)[Ljava/lang/String;

    move-result-object v2

    invoke-static {v2}, Lrexsee/core/utilities/Json;->toJson([Ljava/lang/String;)Ljava/lang/String;
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v2

    .line 44
    :goto_0
    return-object v2

    .line 43
    :catch_0
    move-exception v2

    move-object v1, v2

    .line 44
    .local v1, "e":Ljava/io/IOException;
    const-string v2, "[]"

    goto :goto_0
.end method
